package com;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

/**
 * @author wbzs,
 * @date 2022/10/22,
 * @time 20:15,
 */
@SpringBootApplication
@EnableZuulProxy
public class AppStart09 {
    public static void main(String[] args) {
        System.err.println("hhhhhhhhh");
        SpringApplication.run(AppStart09.class, args);
    }

    /**
     * 通过一个表达式类型的对象将我们的映射规则修改为对应版本号的
     * @return
     */
    @Bean
    public PatternServiceRouteMapper serviceRouteMapper() {
        return new PatternServiceRouteMapper(
                //参数1 服务名字的规则必须是 xxxxxx-vbanben这样的
                //参数2 映射后的方式就是/vbanben/xxxxxx
                "(?<name>^.+)-(?<version>v.+$)",
                "${version}/${name}");
    }
}
